#ifndef TREENODE_H
#define TREENODE_H

#include <glib.h>

typedef struct _TreeNode TreeNode;
typedef struct _TreeNodeType TreeNodeType;

struct _TreeNode {
	const TreeNodeType* type;
	TreeNode* nextSibling;
	TreeNode* firstChild;
	int token;

	char* text;

	struct {
		unsigned int isDynamic  : 1;
		unsigned int isTerminal : 1;
	} bools;

	struct {
		int start;
		int end;
		int col;
		int line;
	} pos;
};

struct _TreeNodeType {
	int (*visit)(TreeNode* /* , visitor */);
};

extern const TreeNodeType treeNodeType;

TreeNode* TreeNode_init(
	TreeNode* self, int token, char* text, int isDynamic,
	int start, int end, int col, int line);

TreeNode* TreeNode_init2(TreeNode* self, int token);

TreeNode* TreeNode_new(
	int token, char* text, int isDynamic, 
	int start, int end, int col, int line);

TreeNode* TreeNode_new2(int token);
TreeNode* TreeNode_new3(int token, ...);

void TreeNode_delete(TreeNode* self);

void TreeNode_addChild(TreeNode* self, TreeNode* child);
void TreeNode_addChildren(TreeNode* self, ...);

#endif /* TREENODE_H */